package com.gitee.wsl.common.ui.ext.path

import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Path
import com.gitee.wsl.math.degreesToRadians
import kotlin.math.sin

// Equilateral triangle angle
private const val AngleEquilateral = 60f


fun Path.triangle(size: Size){
    val edgeLength = size.minDimension
    val height = edgeLength * sin(AngleEquilateral.degreesToRadians())

    translate(
        Offset(
            (size.width - edgeLength) / 2f,
            size.height - (size.height - height) / 2f
        )
    )

    moveTo(0f, height)
    lineTo(edgeLength, height)
    lineTo(edgeLength / 2f, 0f)
    lineTo(0f, height)
}